const koa = require('koa');
// import mockjs from 'mockjs';
const homeRouter = require('./router/home');

const parsed = require("dotenv").config({
  path: '.env.development'
}).parsed;
let port;
if(parsed.VUE_APP_BASE_URL) {
  port = parsed.VUE_APP_BASE_URL.split(":")[2].split('"')[0];
}
const app = new koa();
//跨域设置
const cros = (ctx, next) => {
  ctx.set("Access-Control-Allow-Origin", "*");
  next();
}
app.use(cros);

app.use(homeRouter.routes());
app.use(homeRouter.allowedMethods())

app.listen(port,()=>{
  console.log(`mock服务开启成功,拦截端口${port}`)
})
